package lotus.blog.lotusblog.utils;

import lotus.blog.lotusblog.pojo.User;

public class Util {
    public static boolean checkUserValid(User user){
        String regex = "\\w+@\\w+(\\.\\w{2,3})*\\.\\w{2,3}";
        if (!user.getEmail().matches(regex)){
            return false;
        }else if(user.getPassword().length()<9 || user.getPassword().length()>15 || !user.getPassword().matches("(?=.*[0-9])(?=.*[a-zA-Z]).{9,15}")){
            return false;
        }else if(user.getUsername().length()>15 || user.getUsername().length()==0){
            return false;
        }
        return true;
    }
}
